import {createRouter, createWebHashHistory, createWebHistory} from 'vue-router'

export const constantRoutes = [
    {path: '/', component: () => import('@/views/index.vue'),},
    {path: '/index', component: () => import('@/views/index.vue'),},
    {path: '/progress', component: () => import('@/views/progress/index.vue'),},
    {path: '/login', component: () => import('@/views/login/index.vue'),},
    {path: '/user', component: () => import('@/views/user/index.vue'),},
    {path: '/userCenter', component: () => import('@/views/userCenter/index.vue'),},
]

const router = createRouter({
    //设置前缀路径
    history: createWebHistory(process.env.BASE_URL),
    routes: constantRoutes
})

/**
 * 全局前置路由守卫，每一次路由跳转前都进入这个 beforeEach 函数
 */
router.beforeEach((to, from, next) => {
    next();
});

export default router
